from appium import webdriver
from appium.webdriver.common.appiumby import By
from time import sleep

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '7'
desired_caps['deviceName'] = '127.0.0.1:62001'
desired_caps['app'] = r'C:\apk\kaoyanbang.apk'
desired_caps['appPackage'] = r'com.tal.kaoyan'
desired_caps['appActivity'] = r'com.tal.kaoyan.ui.activity.SplashActivity'
desired_caps['noReset'] = True  # False代表重置（重新安装），默认值就是False

driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
driver.implicitly_wait(10)
sleep(3)

driver.find_element(By.ID,'android:id/button2').click()
driver.find_element(By.ID,'com.tal.kaoyan:id/tv_skip').click()
driver.find_element(By.ID,'com.tal.kaoyan:id/login_email_edittext').send_keys('appuser01')
driver.find_element(By.ID,'com.tal.kaoyan:id/login_password_edittext').send_keys('appuser01')
sleep(2)
driver.find_element(By.ID,'com.tal.kaoyan:id/login_login_btn').click()
sleep(1)
driver.find_element(By.ID,'com.tal.kaoyan:id/mainactivity_button_mysefl').click()
driver.find_element(By.ID,'com.tal.kaoyan:id/activity_usercenter_username').click()
driver.find_element(By.ID,'com.tal.kaoyan:id/activity_myinfo_header_relativelayout').click()
driver.find_element(By.ID,'com.tal.kaoyan:id/item_image').click()
driver.find_element(By.CLASS_NAME,'android.widget.ImageView').click()
sleep(2)
driver.quit()